package common

import (
	"jlpay-sdk-go/pkg/jlpay/core"
	"jlpay-sdk-go/pkg/jlpay/models/trans/common"
	"jlpay-sdk-go/pkg/jlpay/services"
)

// AuthCompleteRefundService 预授权完成退款服务
type AuthCompleteRefundService struct {
	*services.BaseService
}

// NewAuthCompleteRefundService 创建预授权完成退款服务
func NewAuthCompleteRefundService(config *core.Config) *AuthCompleteRefundService {
	return &AuthCompleteRefundService{
		BaseService: services.NewBaseService(config),
	}
}

// AuthCompleteRefund 预授权完成退款
func (s *AuthCompleteRefundService) AuthCompleteRefund(request *common.AuthCompleteRefundRequest) (*common.AuthCompleteRefundResponse, error) {
	response := common.NewAuthCompleteRefundResponse()
	err := s.Post(request, response, "/open/trans/authcompleterefund")
	if err != nil {
		return nil, err
	}
	return response, nil
}
